<?php
/**
 * Eyas start
 *
 * @package   Auto Deploy
 * @author    Eyas <liuyuesongde@163.com>
 * @license   GPL-2.0+
 * @link      http://eyaslife.com
 * @copyright 2015-2016 Eyas
 *
 * @wordpress-plugin
 * Plugin Name: Auto Deploy
 * Plugin URI:  http://eyaslife.com
 * Description: 根据Git源post过来的数据，自动部署更新WordPress网站
 * Version:     0.0.1
 * Author:      Eyas
 * Author URI:  http://eyaslife.com
 * License:     GPL-2.0+
 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain: ey
 * Domain Path: /lang
 */
 define('AUTO_DEPLOY_PLUGIN_DIR',plugin_dir_path( __FILE__ ));
 add_action('init', 'auto_deploy_action' );
 function auto_deploy_action(){
     if(isset($_GET['auto_deploy_action'])){
       deploy();
     }
 }
 function deploy(){
   $logfile = fopen(AUTO_DEPLOY_PLUGIN_DIR."log/deploy-".date('Y-m-d-H-i-s').".log", "w") or die("Unable to open file!");
   if(true){
     fwrite($logfile,'POST DATA:\n'.json_encode($_POST).' \r\n\r\n\r\n\r\n ');
     $systemLogtext=`npm run update`;
     fwrite($logfile,$systemLogtext);
   }
   fclose($logfile);
 }
 ?>
